#define _CRT_SECURE_NO_WARNINGS 1


#include<vector>
#include<iostream>

using namespace std;

int main()
{
	int n = 0, m = 0;
	cin >> n >> m;
	vector<long long> v(n + 1), dp(n + 1);
	for (int i = 1; i <= n; i++)
	{
		cin >> v[i];
		dp[i] = dp[i - 1] + v[i];
	}
	while (m--)
	{
		int left = 0, right = 0;
		cin >> left >> right;
		cout << dp[right] - dp[left - 1] << endl;
	}

	return 0;
}